
package gal.game.util
{
	import flash.display.DisplayObjectContainer;
	
	/**
	 * @author 缺硒
	 */
	public class InstanceUtil
	{
		public static function create(instance:*, parent:DisplayObjectContainer = null,  vars:Object = null):*
		{
			if(instance == null) throw new Error("instance is null");
			
			if(vars != null)
			{
				for(var key:String in vars)
				{
					instance[key] = vars[key];
				}
			}
			
			if(parent != null) parent.addChild(instance);
			
			return instance;
		}
	}
}